package Serializable_package;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

class SuperAnimal
{
	public SuperAnimal()
	{
		System.out.println("SuperAnimal");
	}
}
class SubDog extends SuperAnimal implements Serializable
{
	public SubDog()
	{
		System.out.println("SubDog");
	}
}
public class SuperNotSerializable 
{
	public static void main(String[] args) 
	{
		SubDog d = new SubDog();
		try 
		{
			FileOutputStream fs = new FileOutputStream("testSer.ser");
			ObjectOutputStream os = new ObjectOutputStream(fs);
			os.writeObject(d);
			os.close();
		} 
		catch (Exception e) 
		{
			e.printStackTrace();
		}
		try 
		{
			FileInputStream fis = new FileInputStream("testSer.ser");
			ObjectInputStream ois = new ObjectInputStream(fis);
			d = (SubDog) ois.readObject();
			ois.close();
		} 
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
}
